<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateWxtjUser extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //用户增减数据
        Schema::create('wxtj_user_summarys', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->string('appid', 64)->default('')->comment('微信应用ID');
            $table->date('ref_date')->comment('数据的日期');
            $table->unsignedInteger('user_source')->default(0)->comment('用户的渠道');
            $table->unsignedInteger('new_user')->default(0)->comment('新增的用户数量');
            $table->unsignedInteger('cancel_user')->default(0)->comment('取消关注的用户数量');
            $table->timestamps();
            $table->index(['appid','ref_date','user_source'], 'idx_1');
        });
        //累计用户数据
        Schema::create('wxtj_user_cumulates', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->string('appid', 64)->default('')->comment('微信应用ID');
            $table->date('ref_date')->comment('数据的日期');
            $table->unsignedInteger('cumulate_user')->default(0)->comment('总用户量');
            $table->timestamps();
            $table->index(['appid','ref_date'], 'idx_1');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('wxtj_user_summarys');
        Schema::dropIfExists('wxtj_user_cumulates');
    }
}
